﻿
using Anno.DynamicApi;
using System;
using System.Collections.Generic;
using System.Text;

namespace Anno.DynamicApi
{
    /// <summary>
    /// 远程api调用基本信息
    /// </summary>
    public class RemoteUriInfo
    {
        public string Name { get; set; }
        public string BaseUri { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
        public System.Xml.XmlNode XMLNode { get; set; }
        public RemoteUriInfo()
        {
        }
        public RemoteUriInfo(System.Xml.XmlNode xmlNode)
        {
            Init(xmlNode);
        }
        public void Init(System.Xml.XmlNode xmlNode)
        {
            try
            {
                XMLNode = xmlNode;
                if (xmlNode == null || xmlNode.NodeType == System.Xml.XmlNodeType.Comment)
                {
                    return;
                }
                Name = xmlNode.GetXmlNodeAttributeValue("Name");
                BaseUri = xmlNode.GetXmlNodeAttributeValue("BaseUri");

                Remark = xmlNode.GetXmlNodeAttributeValue("Remark", Name);
            }
            catch { }
        }
        /// <summary>
        /// 返回JSON对象
        /// </summary>
        public object JObject { get { return DicAttrs; } }

        public virtual System.Collections.Generic.IDictionary<string, object> DicAttrs
        {
            get
            {
                var ret = new System.Dynamic.ExpandoObject();
                System.Collections.Generic.IDictionary<string, object> dyret = ret;

                dyret["Name"] = Name;
                dyret["BaseUri"] = BaseUri;
                dyret["Remark"] = Remark;

                return ret;
            }
        }
    }
}
